<%= stylesheet_link_tag "calendar" %>
<script type="text/javascript">
jQuery(document).ready(function(){ 
  jQuery('#calendar_list').datepicker({
    onSelect: function(date) { 
        <%= remote_function(:url => { :action => "form", :act => "verify" }, :with => "'date='+date" ) %>
    },
    beforeShowDay: displayDays,
    loadDaysOfMonth: loadDaysOfMonth,
    dateFormat: 'yy/mm/dd'
  });
});

var dayoff = []; 

function loadDaysOfMonth(month){
    month = (month<10)?"0"+month:month;
    jQuery.ajax({
        url: '/calendar/dayoffmonth?begindate=2008/'+month+'/01&finaldate=2008/'+month+'/31',
        type: 'GET',
        dataType: 'json',
        timeout: 1000,
        async: false,
        error: function(){
            alert('Desculpe, ocorreu um erro na recuperação dos dias, tente novamente, obrigado.');
        },
        success: function(json){
            dayoff = json;
        }
    });
}

function displayDays(date) { 
    if(date.getDay() == 0 || date.getDay() == 6){
        return [true, ''];
    } 
    for (i = 0; i < dayoff.length; i++) { 
        if (date.getDate() == dayoff[i][0]) { 
            return [true, 'holidays']; 
        } 
    }
    return [true, '']; 
} 
</script>
<div id="contentleft"></div>
<div id="contentcenter">
  <h1>Calendario <span id="calendar_add">&nbsp;</span> </h1>
    <div id="calendar_list" class="calendar"></div>
    <div id="calendar_form"></div>
</div>
